<template>
    <div class="my-product">
        <h3>标题: {{ title }}</h3>
        <p>价格: {{ price }}元</p>
        <p>促销活动：{{ intro }}</p>
        <button @click="subFn">宝刀砍一刀</button>
    </div>
    <!-- <hr> -->
    <!-- <div class="my-product">
        <h3>标题: {{ item.title }}</h3>
        <p>价格: {{ item.price }}元</p>
        <p>促销活动：{{ item.intro }}</p>
        <button @click="subFn">宝刀砍一刀</button>
    </div> -->
</template>
<script>
export default {
    props: ['index','title', 'price', 'intro'],
    //props: ['item'],
    methods: {
        subFn() { 
            this.$emit('subprice',this.index,1) //子组件通知父组件，传递参数index和1
        }
    }
}
  
</script>
<style>
.my-product {
    width: 400px;
    padding: 20px;
    border: 2px solid #000;
    border-radius: 5px;
    margin: 10px;
}
</style>